package com.srd.phone.utils.share;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.shengrongdai.srd.R;

import cn.sharesdk.framework.PlatformActionListener;

public class ShareDialog extends Dialog implements View.OnClickListener {


    private String mContentTalk;
    private Activity mActivity;
    private PlatformActionListener mListener;
    private String mTitle;
    private String mContent;
    private String mUrl;

    public ShareDialog(Activity context) {
        super(context, R.style.dialog);
        mActivity =context;
        initView();
    }

    public ShareDialog(Activity activity,String title,String content,String contentTalk,String url,PlatformActionListener listener){
        this(activity);
        mTitle=title;
        mContent=content;
        mContentTalk=contentTalk;
        mUrl=url;
        mListener=listener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.dialog_share);
    }

    private void initView() {
        findViewById(R.id.tv_share_weixin).setOnClickListener(this);
        findViewById(R.id.tv_share_weixin_circle).setOnClickListener(this);
        findViewById(R.id.tv_share_qq).setOnClickListener(this);
        findViewById(R.id.tv_share_qq_space).setOnClickListener(this);
        findViewById(R.id.tv_share_sina).setOnClickListener(this);
        findViewById(R.id.tv_share_message).setOnClickListener(this);

        getWindow().setWindowAnimations(R.style.dialogWindowAnim);
        getWindow().setGravity(Gravity.BOTTOM);
        getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
        setCanceledOnTouchOutside(true);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.tv_share_weixin:
                ShareUtils.showShare(mActivity, ShareUtils.TYPE_WEIXIN, false, mTitle, mContentTalk,mUrl, mListener);
                break;
            case R.id.tv_share_weixin_circle:
                ShareUtils.showShare(mActivity, ShareUtils.TYPE_WEIXIN_CIRCLE, false, mTitle, mContent,mUrl, mListener);
                break;
            case R.id.tv_share_qq:
                ShareUtils.showShare(mActivity, ShareUtils.TYPE_QQ, false, mTitle, mContentTalk,mUrl, mListener);
                break;
            case R.id.tv_share_qq_space:
                ShareUtils.showShare(mActivity, ShareUtils.TYPE_QZONE, false, mTitle, mContent, mUrl, mListener);
                break;
            case R.id.tv_share_sina:  //

                break;
            case R.id.tv_share_message:

                break;
        }
    }

    public void setTitle(String title){
        mTitle=title;
    }
    
    public void setContent(String content){
        mContent=content;
    }
    public void setUrl(String url){
        mUrl=url;
    }
    public void setPlatformActionListener(PlatformActionListener listener){
        mListener=listener;
    }

}
